#pragma once

#include "doc/normal_document.h"
#include "util/status.h"

namespace hawking {
namespace indexlib {

#pragma pack(1)
struct TermMetaUnit {
    size_t term_key;
    size_t offset_in_datafile;
    uint32_t doclist_length;

    TermMetaUnit(size_t t, size_t o, uint32_t d) :
        term_key(t), offset_in_datafile(o), doclist_length(d) {}
};
#pragma pack()

class TermIterator {
public:
    TermIterator() = default;
    virtual ~TermIterator() = default;

    // 1. judge it first
    virtual bool HasNext() const = 0;
    // 2. get value second
    virtual void Value(uint64_t* term) const = 0;
    // 3. shift next third
    virtual void Next() = 0;
};

class InvertedIndexer {
public:
    InvertedIndexer() = default;
    virtual ~InvertedIndexer() = default;

    virtual Status Lookup(
        uint64_t term_key, uint32_t topk, SegmentContext* segment_ctx) = 0;
    
    virtual Status UpdateDocument(
        uint64_t old_term, uint64_t new_term, DocId doc_id) = 0;
};

}
}